package org.xm.sk.vo.tb;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.xm.sk.vo.Base;

import com.fasterxml.jackson.annotation.JsonIgnore;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
@Table(name = "dc_price")
@ApiModel(value = "Price", parent = Base.class, description = "发型师的项目价格")
public class Price extends Base {

    /**
     * 
     */
    private static final long serialVersionUID = -9013746591944165336L;

    @ApiModelProperty(value = "价格名称")
    @Column(length = 255)
    private String name;

    @ApiModelProperty(value = "价格值")
    @Column
    private Double price;

    @ApiModelProperty(value = "此项目价格下的佣金比例")
    @Column
    private Double brokerage;

    @ApiModelProperty(value = "项目价格所属发型师")
    @JsonIgnore
    @ManyToOne(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinColumn(name = "dc_hairdresser_id")
    private Hairdresser hairdresser;

    @ApiModelProperty(value = "价格所属项目")
    @JsonIgnore
    @ManyToOne(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY)
    @JoinColumn(name = "dc_item_id")
    private Item item;
    
    @ApiModelProperty(value = "价格所属项目ID")
    @Transient
    private Integer itemId;
    
    @ApiModelProperty(value = "价格所属发型师ID")
    @Transient
    private Integer hairdresserId;
    
    @ApiModelProperty(value = "项目名称")
    @Transient
    private String itemName;
    
    @ApiModelProperty(value = "发型师名称")
    @Transient
    private String hairdresserName;

    @ApiModelProperty(value = "价格关联订单")
    @JsonIgnore
    @OneToMany(cascade = {
            CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "prices")
    @Fetch(FetchMode.SUBSELECT)
    private Set<Boder> boders = new HashSet<Boder>(0);
    
}
